﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cocos2d;
using Meteorite;
using Microsoft.Xna.Framework;
using System.Diagnostics;
using ChaseCameraSample;

using OpenXLive;
using OpenXLive.Forms;
using OpenXLive.Features;
using Microsoft.Xna.Framework.Input;

namespace Meteorite
{
    public class StatsticsScene : CCScene, ICCTargetedTouchDelegate
    {        
        public StatsticsScene()
        {
            CCSize size = CCDirector.sharedDirector().getWinSize();

            //Title
            CCPoint p = new CCPoint(GameConstant.Point_CenterTop.x, GameConstant.Point_CenterTop.y-40);
            CCLabelBMFont Title = CCLabelBMFont.labelWithString("Statstics", GameConstant.Font_Futura_48);
            addChild(Title);
            Title.position = p;
            Title.scale = 2.0f;

            const float scale = 0.8f;
            const float offset = -40;
            CCPoint AnchorPoint = new CCPoint(0, 0);
            //
            CCPoint p1 = new CCPoint(0+60, p.y + offset*3);
            int n1 = UserData.Instance().GetValue(GameConstant.UserData_TotalGamesPlayed);
            string s1 = string.Format("{0,-20}{1,20}", GameConstant.UserData_TotalGamesPlayed, n1);
            CCLabelBMFont t1 = CCLabelBMFont.labelWithString(s1, GameConstant.Font_Futura_48);
            t1.scale = scale;
            t1.position = p1;
            t1.anchorPoint = AnchorPoint;
            addChild(t1);

            CCPoint p2 = new CCPoint(p1.x, p1.y + offset);
            int n2 = UserData.Instance().GetValue(GameConstant.UserData_HighScore);
            string s2 = string.Format("{0,-20}{1,20}", GameConstant.UserData_HighScore, n2);
            CCLabelBMFont t2 = CCLabelBMFont.labelWithString(s2, GameConstant.Font_Futura_48);
            t2.scale = scale;
            t2.position = p2;
            t2.anchorPoint = AnchorPoint;
            addChild(t2);

            CCPoint p3 = new CCPoint(p2.x, p2.y + offset);
            int n3 = UserData.Instance().GetValue(GameConstant.UserData_TotalPlayTime);
            string s3 = string.Format("{0,-20}{1,20}", GameConstant.UserData_TotalPlayTime, TimeSpan.FromSeconds(n3).ToString());
            CCLabelBMFont t3 = CCLabelBMFont.labelWithString(s3, GameConstant.Font_Futura_48);
            t3.scale = scale;
            t3.position = p3;
            t3.anchorPoint = AnchorPoint;
            addChild(t3);

            CCPoint p4 = new CCPoint(p3.x, p3.y + offset);
            int n4 = UserData.Instance().GetValue(GameConstant.UserData_LastPlayTime);
            string s4 = string.Format("{0,-20}{1,20}", GameConstant.UserData_LastPlayTime, TimeSpan.FromSeconds(n4).ToString());
            CCLabelBMFont t4 = CCLabelBMFont.labelWithString(s4, GameConstant.Font_Futura_48);
            t4.scale = scale;
            t4.position = p4;
            t4.anchorPoint = AnchorPoint;
            addChild(t4);

            CCPoint p5 = new CCPoint(p4.x, p4.y + offset);
            int n5 = UserData.Instance().GetValue(GameConstant.UserData_ColideStone);
            string s5 = string.Format("{0,-20}{1,20}", GameConstant.UserData_ColideStone, n5);
            CCLabelBMFont t5 = CCLabelBMFont.labelWithString(s5, GameConstant.Font_Futura_48);
            t5.scale = scale;
            t5.position = p5;
            t5.anchorPoint = AnchorPoint;
            addChild(t5);

            CCPoint p6 = new CCPoint(p5.x, p5.y + offset);
            int n6 = UserData.Instance().GetValue(GameConstant.UserData_TotalStone);
            string s6 = string.Format("{0,-20}{1,20}", GameConstant.UserData_TotalStone, n6);
            CCLabelBMFont t6 = CCLabelBMFont.labelWithString(s6, GameConstant.Font_Futura_48);
            t6.scale = scale;
            t6.position = p6;
            t6.anchorPoint = AnchorPoint;
            addChild(t6);


            CCPoint p7 = new CCPoint(p6.x, p6.y + offset);
            int n7 = UserData.Instance().GetValue(GameConstant.UserData_TotalBounus);
            string s7 = string.Format("{0,-20}{1,20}", GameConstant.UserData_TotalBounus, n7);
            CCLabelBMFont t7 = CCLabelBMFont.labelWithString(s7, GameConstant.Font_Futura_48);
            t7.scale = scale;
            t7.position = p7;
            t7.anchorPoint = AnchorPoint;
            addChild(t7);
            //MenuGetIn();

        }
        public override void onEnter()
        {
            CCTouchDispatcher.sharedDispatcher().addTargetedDelegate(this, 0, true);
            base.onEnter();
        }

        public override void onExit()
        {
            CCTouchDispatcher.sharedDispatcher().removeDelegate(this);
            base.onExit();
        }
        public virtual void ccTouchEnded(CCTouch touch, CCEvent eventer)
        {
            
        }
        public virtual bool ccTouchBegan(CCTouch touch, CCEvent eventer)
        {
            CCDirector.sharedDirector().popScene();
            return true;
        }

        public virtual void ccTouchMoved(CCTouch touch, CCEvent eventer)
        {
        
        }

        public void ccTouchCancelled(CCTouch pTouch, CCEvent pEvent)
        {
        }
        private void MenuGetIn()
        {
            /*
            CCSize size = CCDirector.sharedDirector().getWinSize();
            Title.runAction(CCMoveTo.actionWithDuration(0.8f, new CCPoint(size.width / 2, size.height - 100)));

            Score.runAction(CCMoveTo.actionWithDuration(0.5f, new CCPoint(size.width / 2, size.height - 250)));

            ButtonPlayAgain.runAction(CCMoveTo.actionWithDuration(0.6f, new CCPoint(size.width / 2, size.height - 300)));
            ButtonMenu.runAction(CCMoveTo.actionWithDuration(0.7f, new CCPoint(size.width / 2, size.height - 350)));
             * */

        }
        private void MenuGetOut()
        {
            /*
            CCSize size = CCDirector.sharedDirector().getWinSize();
            Title.runAction(CCMoveTo.actionWithDuration(0.8f, new CCPoint(size.width / 2, size.height + 60)));

            Score.runAction(CCMoveTo.actionWithDuration(0.8f, new CCPoint(size.width / 2, -size.height)));

            ButtonPlayAgain.runAction(CCMoveTo.actionWithDuration(0.5f, new CCPoint(size.width / 2, -size.height)));
            ButtonMenu.runAction(CCMoveTo.actionWithDuration(0.2f, new CCPoint(size.width / 2, -size.height)));
             * */
        }
    }
}
